package com.htfyun.fragment.settings;

import android.content.ComponentName;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemProperties;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.htfyun.utils.UsefulUtils;

import org.geometerplus.zlibrary.ui.android.R;

import me.yokeyword.fragmentation.SupportFragment;

/**
 * Created by sst on 2018/1/26.
 */

public class SettingsAboutFragment extends SupportFragment {

    public static SettingsAboutFragment newInstance() {

        Bundle args = new Bundle();

        SettingsAboutFragment fragment = new SettingsAboutFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.htfyun_settings_about_fragment, container, false);
        TextView txt = (TextView)view.findViewById(R.id.txtVersion);
        txt.setText(" Launcher Version: " + UsefulUtils.getAppVersion(_mActivity) + "\n Eink Version:"
                + SystemProperties.get("ro.product.version")
        + "\n " + SystemProperties.get("ro.build.description"));
        
        view.findViewById(R.id.btnCalibration).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startPenCalibActivity();
            }
        });

        return view;
    }

    /**
     * 20180403,start the calibration activity at EinkstatusBar,
     * whitch have uid.system priviliage.
     */
    public void startPenCalibActivity() {
        ComponentName comp = new ComponentName("com.htfyun.blackwhitebar",
                "com.htfyun.blackwhitebar.PenCalibActivity" );
        Intent startIntent = new Intent();
        startIntent.setComponent(comp);
        startActivity(startIntent);
    }
    

}
